# -*- coding: utf-8 -*-
from django import forms
from django.conf import settings
from django.contrib.localflavor.br.forms import BRCPFField,BRPhoneNumberField,BRZipCodeField
from django.template.defaultfilters import default

from datetime import date

from intercampi.models import *

#from intercampi_web.util.fields.dateFieldBR import DateFieldBR

from sisbase.forms import fields

class PessoaAdminForm(forms.ModelForm):
    
    cpf = BRCPFField(label='CPF',required=False)
    telefone1 = BRPhoneNumberField(label='Telefone Residencial',required=False)
    telefone2 = BRPhoneNumberField(label='Telefone Comercial',required=False)
    telefone3 = BRPhoneNumberField(label='Celular 1',required=False)
    telefone4 = BRPhoneNumberField(label='Celular 2',required=False)
    dataNascimento = fields.BRDateField(label='Data de Nascimento',
                                  help_text='Formato: DD/MM/AAAA',
                                  required=False)
    dataAtualizacao = fields.BRDateField(initial=date.today(),
                                   label='Data de Atualizacao',
                                   help_text='Formato: DD/MM/AAAA',
                                   required=False)
    
    def clean_rg(self):
        rg = self.cleaned_data.get('rg')
        if rg != '' and not rg.isdigit():
            raise forms.ValidationError('O campo RG deve ser preenchido somente com números.')    
        else:
            return rg
        
    class Meta():
        model = Pessoa

class EnderecoAdminForm(forms.ModelForm):
    
    cep = BRZipCodeField(label='CEP', required=False) 
    
    class Meta():
        model = Endereco
        
class TurmaAdminForm(forms.ModelForm):
    
    dataInicio = fields.BRDateField(label='Data Inicio',
                              help_text='Formato: DD/MM/AAAA',
                              required=False)
    
    class Meta():
        model = Turma
  

